package com.zzg.service.Impl;

import com.zzg.entity.ShowMap;
import com.zzg.mapper.ShowMapMapper;
import com.zzg.service.ShowMapService;
import com.zzg.util.MapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zzg
 * @version 1.0.0
 * @ClassName：ShowMapServiceImpl
 * @Description: 描述
 * @date 2021/7/20
 **/
@Service
public class ShowMapServiceImpl implements ShowMapService {
    @Autowired
    private ShowMapMapper showMapMapper;


    @Override
    public List<ShowMap> selectMap() {
        List<ShowMap> showMaps = showMapMapper.selectMap();
        for (ShowMap showMap : showMaps) {
            ShowMap coordinate = MapUtil.getCoordinate(showMap.getSite());
            showMap.setiPX(coordinate.getiPX());
            showMap.setiPY(coordinate.getiPY());
        }
        return showMaps;
    }

    @Override
    public List<ShowMap> driverMap(String id) {
        System.out.println(id);
        ShowMap showMap = showMapMapper.driverMap(id);
        List<ShowMap> showMaps =new ArrayList<>();
        ShowMap coordinate = MapUtil.getCoordinate(showMap.getOne());
        ShowMap coordinate1 = MapUtil.getCoordinate(showMap.getTwo());
        ShowMap one = new ShowMap();
        ShowMap two = new ShowMap();
        one.setiPX(coordinate.getiPX());
        one.setiPY(coordinate.getiPY());
        two.setiPX(coordinate1.getiPX());
        two.setiPY(coordinate1.getiPY());
        showMaps.add(one);
        showMaps.add(two);
        return showMaps;
    }
}
